package org.example.test.bean;

import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;
import org.hibernate.annotations.GenericGenerator;

import javax.persistence.*;
import java.math.BigDecimal;
import java.math.BigInteger;

/**
 * @program: example-web-framework-extends-2x
 * @description:
 * @author: Chenjiabin
 * @create: 2018/11/20 8:09
 **/
@DynamicUpdate(true)
@DynamicInsert(true)
@Entity
public class User {
    @Id
    @GenericGenerator(name = "uuidGenerator", strategy = "uuid")
    @GeneratedValue(generator = "uuidGenerator", strategy = GenerationType.IDENTITY)
    @Column(length = 36, nullable = false)
    protected String id;

    @Column(length = 32)
    private String name;

    @Column
    private BigDecimal money;
    @Column
    private BigInteger age;

    @OneToOne(cascade = CascadeType.ALL, orphanRemoval = true)
    @JoinColumn(name = "user_detail_id")
    private UserDetail detail;

    public User() {
    }

    public BigInteger getAge() {
        return age;
    }

    public void setAge(BigInteger age) {
        this.age = age;
    }

    public BigDecimal getMoney() {
        return money;
    }

    public void setMoney(BigDecimal money) {
        this.money = money;
    }

    public User(String name) {
        this.name = name;
    }

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public UserDetail getDetail() {
        return detail;
    }

    public void setDetail(UserDetail detail) {
        this.detail = detail;
    }
}
